package com.hankol.community.adapter

import com.baselibrary.utils.GlideUtils
import com.baselibrary.utils.TimeUtil
import com.chad.library.adapter.base.BaseQuickAdapter
import com.chad.library.adapter.base.BaseViewHolder
import com.hankol.community.R
import com.hankol.community.bean.PulpitListBean

/**
 * @author: 关忆北、
 * @date: 2022/4/26
 * @Des：讲坛主页 【目录界面--适配器】
 */
class PulpitHomeCatalogueAdapter : BaseQuickAdapter<PulpitListBean, BaseViewHolder>(R.layout.item_pulpit_catalogue) {
    var isLock = false//是否解锁


    override fun convert(helper: BaseViewHolder, bean: PulpitListBean) {
        helper
                .setText(R.id.tv_pulpitCatalogue_title, bean.title)
                .setText(R.id.tv_pulpitCatalogue_time, TimeUtil.getRuleTime(bean.ctime, "yyyy-MM-dd"))
                .setText(R.id.tv_pulpitCatalogue_studySpeed, if (bean.progress == 100L) "| 已学完" else "| 已学${bean.progress}%")
                .setGone(R.id.iv_pulpitCatalogue_lock, !isLock)
                .setGone(R.id.ll_pulCatalogue_lookRecord, bean.lastStudy == 1)
                .setGone(R.id.tv_pulpitCatalogue_studySpeed, bean.progress != 0L)
        GlideUtils.loadImg_101(mContext.applicationContext, bean.cover, helper.getView(R.id.round_pulpitCatalogue_cover))

    }

    fun isLock(b: Boolean) {
        isLock = b
        notifyDataSetChanged()
    }
}